layui.use('form', function(){
});

var vm = new Vue({
    el: '#app',
    data: {
        productName :"",
        productRetailPrice: "",
        productSize: "",
        productDescription:""
    },
    methods: {
        add() {
            var tmp = {
                'productName': vm.productName,
                'productRetailPrice': vm.productRetailPrice,
                'productSize': vm.productSize,
                "productDescription": vm.productDescription,
            };
            var data = JSON.stringify(tmp)
            $.ajax({
                type: "post",
                url: "/copProduct",
                headers: { 'Content-Type': 'application/json;charset=utf-8' },
                dataType: 'json',
                async: true,
                data: data,
                success: function (result) {
                    console.log(result)
                    if (result.code == 500) {
                        layer.msg(result.msg)
                    } else {
                        alert("成功")
                        window.location.href="product.html"
                    }
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    if(xhr.status==403) {
                        alert("无权限")
                        location.reload([true])
                    }
                }
            });
        },
        back(){
            window.location.href="userManger.html"
        }
    }
})